package com.maimao.kill.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.maimao.model.kill.Activity;
import com.maimao.model.kill.Schedule;
import com.maimao.model.kill.input.ScheduleInput;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author MaoLin Wang
 * @date 2021/4/7 10:05 上午
 */
public interface ScheduleMapper extends BaseMapper<Schedule> {

    int updateEnabledByAcId(@Param("acId") Integer id, @Param("enabled") Integer enabled);

    List<Schedule> selectByParams(@Param("input") ScheduleInput scheduleInput);

    int saveBatch(@Param("list") List<Schedule> scheduleList);

    List<Schedule> queryByStarTimeBetween(@Param("fromTime") LocalDateTime fromTime, @Param("endTime") LocalDateTime endTime);

    /**
     * 查询在区间内是否有其他排期
     * (开始时间 >= startTime 且 开始时间 < endTime) || (结束时间 > startTime 且 结束时间 <= endTime)
     * @param startTime 左区间
     * @param endTime 右区间
     */
    List<Schedule> queryExist(@Param("startTime") LocalDateTime startTime,@Param("endTime") LocalDateTime endTime);

}
